home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / sound / compraw.zip / COMPRAW.DOC next >
Text File  |  1992-11-08  |  10KB  |  219 lines

  1. Program: COMPRAW.ZIP (freeware)
  2. Date:    8 November 1992
  3. Version: 1.00
  4. Files:   COMPRAW.EXE
  5.          COMPRAW.DOC
  6.          COMPRAW.PAS
  7.  
  8. Copyright (c) 1992 François Jalbert (jalbert@IRO.UMontreal.CA)
  9.  
  10. A few more copyright notices so everybody is happy:
  11.  
  12.   Sound-Blaster (c) 1989-1991 Creative Labs Inc
  13.   Turbo-Pascal 5.0 (c) 1988 Borland International
  14.   LZEXE 0.91 (c) 1989 Fabrice Bellard
  15.   PKZIP 1.1 (c) 1989-1990 PKWARE Inc
  16.   LHA 2.13 (c) 1988-1991 Haruyasu Yoshizaki
  17.   ARJ 2.20 (c) 1990,91 Robert K Jung
  18.  
  19. Warning! This documentation contains extended characters!
  20.  
  21.  
  22. Description:
  23. ───────────
  24.  
  25. This program will help lossy compress and decompress 8-bit unsigned raw sound 
  26. files. Extensive attention has been paid to efficiency and to robustness. Both 
  27. DOS style and UNIX style syntax is supported. 
  28.  
  29.  
  30. Justification:
  31. ─────────────
  32.  
  33. Since I bought a Sound-Blaster 2.0, I have been sampling various sounds and I 
  34. soon discovered the need to lossy [de]compress samples to save disk space. 
  35.  
  36. The Sound-Blaster supports in hardware a proprietary type of .VOC lossy sound 
  37. compression which is not understood by anybody else, i.e. it is relatively 
  38. useless. 
  39.  
  40. I monitored SIMTEL for about one year, but no freeware/shareware lossy raw 
  41. sound [de]compression ever appeared on it. 
  42.  
  43. So I began contemplating various ways to [de]compress sound using approximate 
  44. dictionary techniques. I looked at the source code of precursors of LHA. I read 
  45. a book on data compression techniques. I even began preliminary Pascal 
  46. programming and got the I/O buffering stuff running. But it was all very 
  47. complicated and I somehow found ways to delay.
  48.  
  49. A few days ago, Mark Cox, the renowned author of MODPLAY, mentioned to me that 
  50. simply zeroing out the least significant bits of raw sounds should be of use 
  51. somehow. What a simple and wonderful idea! COMPRAW was born, and 2 days later, 
  52. this small project was successfully completed. 
  53.  
  54. Feel free to pass along and share copies of my work. If you have any comments 
  55. or suggestions, I would be very happy to hear from you. My internet e-mail 
  56. address can be found at the top of this brief document. 
  57.  
  58.  
  59. Operation:
  60. ──────────
  61.  
  62. The syntax is: COMPRAW <infile> <outfile> /<rate> < /c | /d >
  63.  
  64. where each of the four parameters must be supplied.
  65.  
  66.     <infile>     Input raw sound file
  67.     <outfile>    Output raw sound file
  68.     /<rate>      8 to <rate> compression ratio from 7 (low) to 1 (high)
  69.     < /c | /d >  Compression or Decompression flag
  70.  
  71.  
  72. Functional description:
  73. ───────────────────────
  74.  
  75. Compression is done in two steps:
  76.  
  77.   1) Use COMPRAW /C to log scale and simplify the raw sound.
  78.   2) Use LHA (say) to compress the simplified raw sound file.
  79.  
  80. Decompression is also done in two steps:
  81.  
  82.   1) Use LHA (say) to decompress, yielding the simplified raw sound file.
  83.   2) Use COMPRAW /D to spline and log unscale, yielding the rebuilt raw sound.
  84.  
  85. COMPRAW compression of the raw sound involves two steps:
  86.  
  87.   1) The raw sound is scaled according to a simple log 2 scale. This was 
  88.      required because most of the information lies around 80H. 
  89.   2) The scaled raw sound is subjected to a zeroing of the requested number 
  90.      of least significant bits. Compression rates of 8:7 (poor) to 8:1 (high) 
  91.      are supported. 
  92.  
  93. Here is 8:1 COMPRAW compression of already log scaled raw sound:
  94.  
  95.            FF────────────────────────     FF────────────────────────
  96.              *                   *                                  
  97.                                   * *                               
  98.               *         ***     *                                   
  99.                        *           *        ****      *****   ******
  100.                *                                                    
  101.                            *                                        
  102.                 *              *                                    
  103.            80──────────────────────── ==> 80────────────────────────
  104.                  *    *                                             
  105.                               *                                     
  106.                   *         *                                       
  107.                              *                  ******     ***      
  108.                      *                                              
  109.                    *                                                
  110.                     *                                               
  111.            00────────────────────────     00────────────────────────
  112.  
  113. Once COMPRAW compression is done, your favorite compression utility will have 
  114. no difficulty compressing and decompressing the simplified raw sound file. I 
  115. decided that rather than spend hours redoing what's already available, it was 
  116. better to let expert programs such as LHA do their magic. I also tried to pack 
  117. the simplified raw sound to make long continuous chains of bits, but this 
  118. hinders severely LHA and simply does not pay off. 
  119.  
  120. COMPRAW decompression of the simplified raw sound involves two steps:
  121.  
  122.   1) A simple spline is built in such a way that if the splined raw sound was 
  123.      COMPRAW compressed again (without log scaling), it would be identical to 
  124.      the original simplified raw sound. 
  125.   2) The splined raw sound is unscaled according to the simple log 2 scale. 
  126.  
  127. Here is 8:1 COMPRAW decompression of simplified raw sound:
  128.  
  129.            FF────────────────────────     FF────────────────────────
  130.                                                                     
  131.                                                                     
  132.                                                                     
  133.              ****      *****   ******       ***         *       ****
  134.                                                        * *     *    
  135.                                                *      *   *   *     
  136.                                                                     
  137.            80──────────────────────── ==> 80────────────────────────
  138.                                                                     
  139.                                                 *    *     * *      
  140.                                                  *  *               
  141.                  ******     ***                   **        *       
  142.                                                                     
  143.                                                                     
  144.                                                                     
  145.            00────────────────────────     00────────────────────────
  146.  
  147. The loss of information is obvious, but at least the nasty staircases are gone. 
  148. They are the ones responsible for the hissing background noise in the 
  149. simplified raw sound if it were simply log unscaled. 
  150.  
  151.  
  152. Benchmarks:
  153. ───────────
  154.  
  155. Of course, the first question that comes to one's mind is: How well does such a 
  156. combo COMPRAW-LHA perform? 
  157.  
  158. Well, first of all, I tried PKZIP, ARJ and LHA on various 8KHz simplified raw 
  159. sound. PKZIP was the fastest, but compressed poorly. ARJ and LHA are very 
  160. close, with LHA slightly better. This is all version dependent and I am sure 
  161. that the picture could be completely different in a year or two. But for now, I 
  162. would recommend LHA, or if you require multi-volume capability, ARJ. 
  163.  
  164. For the following comparison, I will use LHA. Here is a typical 8KHz raw sound 
  165. file and how LHA compresses it. This is our reference.
  166.  
  167. 8TO8     RAW    902950 11-08-92  12:00p
  168. 8TO8     LZH    622553 11-08-92  12:01p
  169.  
  170. Now, I use COMPRAW with 8:5, 8:4, 8:3 and 8:2 rates. The simplified raw sound 
  171. is as big as the original raw sound, but when compressed... 
  172.  
  173. 8TO5     LZH    378372 11-08-92  12:02p
  174. 8TO4     LZH    264439 11-08-92  12:03p
  175. 8TO3     LZH    164358 11-08-92  12:04p
  176. 8TO2     LZH     94152 11-08-92  12:05p
  177.  
  178. The space required is respectively 61%, 42%, 26% and 15% of what it would have 
  179. been without COMPRAW. These are typical values. 
  180.  
  181. Sound quality wise, 8:5 sounds as good as the original, 8:4 is very similar, 
  182. 8:3 is definitely different, with some low v